//
//  CAIImagePickerControllerKit.h
//  CAIImagePickerController
//
//  Created by 海参 on 2021/8/24.
//
// 注意：不能继承TZImagePickerController，不然调用只拍照的方法会有bug，第一次调用的时候会弹出是否选择照片的权限弹窗，而不是拍照的权限检查弹窗； CAIImagePickerControllerKit自己初始化实例的时候会直接调用内部权限；

#import <TZImagePickerController/TZImagePickerController.h>
#import <CAIImagePickerControllerKit/ZXUIImagePickerManager.h>
#import <CAIImagePickerControllerKit/CAIPHPickerControllerManager.h>
#import "CAIPickerConfiguration.h"

NS_ASSUME_NONNULL_BEGIN



@class CAIImagePickerControllerKit;
@protocol CAIImagePickerControllerKitDelegate <NSObject>

@optional
// 完成选择后的回调；
// photos数组里的UIImage对象，默认是828像素宽，你可以通过设置photoWidth属性的值来改变它
- (void)imagePickerController:(CAIImagePickerControllerKit *)picker
       didFinishPickingPhotos:(nullable NSArray<UIImage *> *)photos
                 sourceAssets:(nullable NSArray *)assets;


/// 完成选择、取消、因其它原因失败获取图片等只要关闭picker之后的回调；如果调用这个方法，则不会回调上面回调；
/// @param picker 当前对象
/// @param photos 选择之后的图片，如果有裁剪，就是裁减后的图片；
/// @param assets 自定义拍摄多张照片时，是CAICameraPhotoInfoModel集合；
/// @param error 各种异常信息，包括没有权限，取消使用；
- (void)imagePickerController:(nullable CAIImagePickerControllerKit *)picker
         didFinishPickingPhotos:(nullable NSArray<UIImage *> *)photos
                   sourceAssets:(nullable NSArray *)assets
                          error:(nullable NSError *)error;
@end


///记得强引用对象
@interface CAIImagePickerControllerKit : NSObject <TZImagePickerControllerDelegate>

@property (nonatomic, weak) id<CAIImagePickerControllerKitDelegate> caiPickerDelegate;


/// 自定义相机拍照是否需要水印
@property (nonatomic, assign) BOOL watermask;


+ (void)setLocation:(NSString *)location;

///// statusBar的样式，默认为UIStatusBarStyleLightContent
//@property (assign, nonatomic) UIStatusBarStyle statusBarStyle;
//


/// 弹出相册选择-选择图片;允许选择原图，允许拍照，不允许选择视频
/// @param viewController presentingViewController
/// @param delegate 代理
- (void)showImagePickerWithFromViewController:(UIViewController *)viewController
                                     delegate:(id<CAIImagePickerControllerKitDelegate>)delegate
                               maxImagesCount:(NSInteger)maxImagesCount;


/// 弹出相册选择-是否允许选择原图，是否允许拍照,不允许选择视频；
/// @param viewController viewController description
/// @param delegate delegate description
/// @param maxImagesCount 限制选择数量
/// @param allowPickingOriginalPhoto 是否允许选择原图；使用系统PHPicker时候始终是原图；
/// @param allowTakePicture 是否允许拍照，如果允许拍照则弹出三方库TZImagePicker；如果不允许拍照，则使用系统PHPicker；
- (void)showImagePickerWithFromViewController:(UIViewController *)viewController
                                     delegate:(id<CAIImagePickerControllerKitDelegate>)delegate
                               maxImagesCount:(NSInteger)maxImagesCount
                    allowPickingOriginalPhoto:(BOOL)allowPickingOriginalPhoto
                             allowTakePicture:(BOOL)allowTakePicture;


- (void)showImagePickerWithFromViewController:(UIViewController *)viewController
                                     delegate:(id<CAIImagePickerControllerKitDelegate>)delegate
                               maxImagesCount:(NSInteger)maxImagesCount
                    allowPickingOriginalPhoto:(BOOL)allowPickingOriginalPhoto
                             allowTakePicture:(BOOL)allowTakePicture
                            allowPickingImage:(BOOL)allowPickingImage
                            allowPickingVideo:(BOOL)allowPickingVideo;



/// 弹出相册选择-配置对象
/// @param viewController viewController description
/// @param delegate delegate description
/// @param configuration configuration description
- (void)showImagePickerWithFromViewController:(UIViewController *)viewController
                                     delegate:(id<CAIImagePickerControllerKitDelegate>)delegate
                                 configuraton:(nullable CAIPickerConfiguration *)configuration;



/// 直接调用拍照
/// @param sourceController presentingViewController
/// @param delegate 代理
- (void)showCameraControllerWithSourceController:(UIViewController *)sourceController
                                        delegate:(id<CAIImagePickerControllerKitDelegate>)delegate;


/// 直接调用拍照
/// @param sourceController presentingViewController
/// @param delegate 代理
/// @param allowsEditing 是否允许裁剪
- (void)showCameraControllerWithSourceController:(UIViewController *)sourceController
                                        delegate:(id<CAIImagePickerControllerKitDelegate>)delegate
                                   allowsEditing:(BOOL)allowsEditing;


/// 直接调用拍照:定制相机拍多张；
/// @param sourceController sourceController description
/// @param delegate delegate description
/// @param maxTakePhotoNum 最多几张
- (void)showCameraMultiPhotoWithSourceController:(UIViewController *)sourceController
                                        delegate:(id<CAIImagePickerControllerKitDelegate>)delegate
                                 maxTakePhotoNum:(NSInteger)maxTakePhotoNum;


- (void)dismissCamera;

@end

NS_ASSUME_NONNULL_END


/**** 注意：要强引用持有对象，不然会被释放。
 @interface CHSTakeTaskController ()
 
 @property (nonatomic, strong) CAIImagePickerControllerKit *imagePicker;
 
 @end
 
 @implementation CHSTakeTaskController
 
 - (CAIImagePickerControllerKit *)imagePicker{
     if (!_imagePicker) {
         _imagePicker = [[CAIImagePickerControllerKit alloc] init];
     }
     return _imagePicker;
 }
 
 - (void)show{
    [self.imagePicker showImagePickerWithFromViewController:self delegate:self maxImagesCount:(3-self.photosMArray.count)];
 }
 */
